<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/sys/resources/css/reset.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/style.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/invalid.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/bootstrap.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/bootstrap-datetimepicker.min.css" type="text/css" media="screen"/>

    <script type="text/javascript" src="/sys/resources/scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/zhTable.js"></script>

    <script type="text/javascript" src="/sys/resources/scripts/simpla.jquery.configuration.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/facebox.js"></script>

    <title>管理员帐号</title>
    <script >
        function initData(tds,data,index)
        {
            $(tds[0]).html("<input type='checkbox' name='key' value='"+data.uid+"'>");
            $(tds[1]).html(data.passport);
            $(tds[2]).html(data.roleid);
            $(tds[3]).html(data.lastlogintime);
            $(tds[4]).html(data.regtime);
            $(tds[5]).html(data.count);
            var sta = "屏蔽"
            if(data.status=="1")
            {
                sta = "正常";
            }
            $(tds[6]).html(sta);
            var oper = "<a type='button' class='bottom btn-info btn-sm' href='/sys/sysUser/edit.do?id="+data.uid+"'>编辑</a>" +
                    "<button type='button' class='bottom btn-info btn-sm' onclick='removeData(this,"+data.uid+",\"/sys/sysUser/del.do\");return false;'>删除</button>"
            $(tds[7]).html(oper);
        }
        $(function () {
            initZhTable($("#tablePageDiv"), initData);

            //初始化时间插件
            $('.form_datetime').datetimepicker({
                format: 'yyyy-mm-dd',
                language: 'zh-CN',
                weekStart: 1,
                todayBtn: 1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                minView: 2,
                forceParse: 0
            }).click(function () {
                $(this).val("");
            });
        });
    </script>

</HEAD>
<BODY class="mian_bg">
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
    <TR height=28>
        <TD class="addr_td">&nbsp;&nbsp;<img src="/sys/resources/images/addr_icon.png">&nbsp;当前位置: 系统设置>管理员帐号</TD>
    </TR>
    <TR>
        <TD bgColor=#7ca600 height=1></TD>
    </TR>
    <TR>
        <TD bgColor=#8ebe00 height=1></TD>
    </TR>
</TABLE>

<div id="main-content">
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>管理员帐号</h3>

            <div class="clear"></div>
        </div>
        <div class="content-box-content">
            <div class="container">
                <div id="tablePageDiv">
                    <div id="searchDiv">
                        <form name="searchDivForm" url="/sys/sysUser/query.do">
                            <div class="row">
                                <div class="col-xs-10">

                                    <div class="col-xs-4">
                                        <div class="input-group">
                                            <span class="input-group-addon">用户名</span>
                                            <input type="text" name="passport" value="" readonly class="form_datetime form-control">
                                        </div>
                                    </div>

                                    <div class="col-xs-4">
                                        <div class="input-group">
                                            <span class="input-group-addon">角色id</span>
                                            <input type="text" name="roleid" value="" readonly class="form_datetime form-control">
                                        </div>
                                    </div>

                                    <div class="col-xs-4">
                                        <div class="input-group">
                                            <span class="input-group-addon">注册日期</span>
                                            <input type="text" name="regtime" value="" readonly class="form_datetime form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-2">
                                    <button type="button" class="btn btn-success btn-block searchBtn">查询</button>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-xs-2">
                                    <button type="button" class="btn btn-success btn-block searchBtn">查询</button>
                                </div>
                                <div class="col-xs-2">
                                    <a href="/sys/sysUser/add.do" class="btn btn-success btn-block searchBtn">增加</a>
                                </div>
                                <div class="col-xs-2">
                                    <button type="button" onclick="removeData(this,'checkList','/sys/sysUser/del.do');return false;" class="btn btn-success btn-block searchBtn">删除</button>
                                </div>

                            </div>
                        </form>
                    </div>

                    <div id="tableDiv" style="margin-top: 10px;">
                        <table class="table table-hover table-bordered .table-condensed">
                            <thead>
                            <tr  class="bg-success">
                                <th></th>
                                <th>管理账号</th>
                                <th>所属权限组</th>
                                <th>最后登录时间</th>
                                <th>注册时间</th>
                                <th>次数</th>

                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                        <ul class="pagination">

                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    /**
     * 选中列表中的全部
     * @param id
     */
    function checkAll(id) {
        $("#" + id + " tbody tr:not([disabled]) input[name='key']").each(function() {
            if (this.checked)
                this.checked = false;
            else
                this.checked = true;
        });
    }

    /**
     * 删除选择的列表项
     * @param obj
     * @param id
     * @param dealUrl   处理的地址
     */
    function removeData(obj, id, dealUrl) {
        var ids = new Array();

        if (isNaN(id)) { //判断Id不是数字
            $("#" + id + " input:checked[name='key']").each(function() {
                ids.push(this.value);
            });

        } else {
            ids.push(id);
        }

        ids = ids.join(',');  //用户‘，’号连接id串
        if (ids == '')
            return false;

        if (!window.confirm("危险操作，你确定删除吗？"))   //确定是否删除
            return false;

        var query = new Object();
        query.id = ids;

        //发起请求 提交数据
        $.ajax({
            url: dealUrl,
            type:"POST",
            cache: false,
            data:query,
            dataType:"json",
            success: function(result) {
                if (result.num == '-1') {
                    alert("删除异常！");
                }
                else {
                    alert("成功，删除" + result.num + "个！")
                    window.location.reload();
                }
            },
            error : function() {
                alert("请求异常");
            }
        });
    }

    function getPage(pid) {
        var htmlobj = $.ajax({url:"/money/flow/flowList.do?page=" + pid, cache:false, async:false})
        $("#lists").html(htmlobj.responseText);
    }
</script>

<c:if test="${not empty msg}">
    <script type="text/javascript">
        alert(msg);
    </script>
</c:if>
</BODY>
</HTML>